import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double in_balance = sc.nextDouble();       // 输入存款余额（原始金额）
        double deposit_money = sc.nextDouble();   // 输入目前需要存款的金额
        double withdraw_money = sc.nextDouble();  // 需要取出的金额
        double withdraw_money2 = sc.nextDouble();  // 需要取出的金额
        Account pepole = new Account();
        pepole.deposit(in_balance,deposit_money);   // 存款
        System.out.println();
        pepole.withdraw(withdraw_money);       // 第一次取款
        System.out.println();
        pepole.withdraw(withdraw_money2);       // 第二次取款
        System.out.println();
        pepole.refer();        // 查询
    }
}

class Account{
    private String account; // 账号
    private String name;   // 储蓄姓名
    private String address;  // 地址
    private double balance; // 存款余额----> 很重要，理解这个
    private  double minblance = 100;  // 最小余额

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getMinblance() {
        return minblance;
    }

    public void setMinblance(double minblance) {
        this.minblance = minblance;
    }


    //用户存款
    public double deposit( double in_balance,double deposit_money){
        balance = in_balance;
//        if(balance == 0.0){
//            balance = minblance;
//        }
        System.out.println("您的存款余额为"+balance+"元");
        System.out.println("存入"+deposit_money+"元");
        balance += deposit_money;
        System.out.println("您存款后的余额为"+balance+"元");
        return balance;
    }
    // 用户取款
    public double withdraw(double withdraw_money){
        System.out.println("您要取出的金额为"+withdraw_money+"元");
        if((balance-withdraw_money)<minblance){  // 如果取款的金额太大，操作将失败
            System.out.println("操作失败！至少保留余额为"+minblance+"元");
        }else{
            balance -= withdraw_money;
            System.out.println("操作成功！您的存款余额为"+balance+"元");
        }
        return balance;
    }
    // 用户查询
    public double refer(){
        System.out.println("您现在的存款余额为"+balance+"元");
        return balance;
    }
}
